<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<%@include file="/WEB-INF/ibnms/common/easyui.jsp" %>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>冻结帐户列表</title>
		<link href="<%=application.getContextPath()%>/nresources/ued/css/all-src.css" type="text/css" rel="stylesheet" />
		<%@include file="/WEB-INF/ibnms/common/jqgrid.jsp"%>
	</head>
<body>
<div class="form-wrapper">
    	<div class="form-title">
       		 <span class="ttcorner"></span>
             <h3>
                <span class="text">冻结账户</span>
             </h3>
        </div>
        <div class="box-in">
            <table border="0" cellspacing="0" cellpadding="0" class="table-03">
	            <tr>
		         	<td class="monitor_bg1" height="13" align ="right" nowrap>
		         		登录名：
			         	<input  type="text" class="input-style1" name="userForm.userId"/>
			     		姓名：
			         	<input  type="text" class="input-style1" name="userForm.userName"/>
			         	 <input type="button" class="btn-style02" id="btn-search" value="查询" />
			         </td>
		   		</tr>
            </table>
        </div>
        <div class="title-style"><a class="fold-tip"></a></div>
     	<div id="frozen-form" class="block02">
     		<div class="title-style02">
				<input class="btn-style02" type="button" id="btn-cancel" value="取消冻结" />
				<input class="btn-style02" type="button" name="btn-switch" value="设置冻结">
            </div>
			<table id="frozen-gridTable">
			</table>
			<div id="frozen-gridPager">
			</div>
		</div>
		<div id="unforzen-form" class="block02" style='display:none;'>
     		<div class="title-style02">
				<input class="btn-style02" type="button" id="btn-frozen" value="冻结账户"/>
				<input class="btn-style02" type="button" name="btn-switch" value="返回"/>
            </div>
			<table id="unfrozen-gridTable">
			</table>
			<div id="unfrozen-gridPager">
			</div>
		</div>
</div>   
 
</body>
	<script type="text/javascript">
		$("#btn-search").click(function(){
			$("#frozen-gridTable").trigger("reloadGrid",[{page:1}]);
			$("#unfrozen-gridTable").trigger("reloadGrid",[{page:1}]);
		});
			
		$(function(){
			$("#frozen-gridTable").jqGrid({
				url: "frozenListQueryJson.do",
				datatype: "json",
				mtype: "POST",
				height: "100%",
				autowidth: true,
				colNames:['登录名', '姓名', '电话', '电子邮箱'],
				colModel:[
					{name:'LOGIN_ID',index:'LOGIN_ID'},
					{name:'NAME',index:'NAME'},
					{name:'LOGIN_PHONE',index:'LOGIN_PHONE'},
					{name:'EMAIL_ADDR',index:'EMAIL_ADDR'}
				],
				viewrecords: true,
				rowNum: 15,
				rowList: [10,15,30],
				sortname: 'NAME',
				jsonReader: {
					root: 'rows',
					page: 'page',
					total: 'total',
					records: 'records',
					repeatitems: false,
					subgrid: {
				        root: 'rows',
						page: 'page',
						total: 'total',
						records: 'records',
						repeatitems: false
				    }      
				},
				pager: "#frozen-gridPager",
				hidegrid: true,
				multiselect: true,
				beforeRequest:function(){
					var postData = {};
					$(":input[name^='userForm.']").each(function(){
						postData[$(this).attr("name")] = $(this).val();
					});
					$.extend($("#frozen-gridTable").getGridParam("postData"), postData);
				}
			});
			$("input[name='btn-switch']").click(function(){
				$("#frozen-form").toggle('fast');
				$("#unforzen-form").toggle('fast');
				$("#frozen-gridTable").trigger('reloadGrid');
				$("#unfrozen-gridTable").trigger('reloadGrid');
			});
		}); 
		$("#btn-cancel").click(function() {
				var idArr = jQuery("#frozen-gridTable").jqGrid('getGridParam','selarrrow');
				switch (idArr.length) {
					case 0:
						alert("请先选择一个账户!");
						break;
					case 1:
						if (confirm("是否要解除该冻结账户?")) {
							var data = jQuery("#frozen-gridTable").jqGrid('getRowData',idArr[0]);
							var LOGIN_ID = data.LOGIN_ID;
							$.ajax({
								type: "POST",
								async: false,
								url: "<s:url action="cancelfrozenUser" namespace='/'/>?userForm.LOGIN_ID="+LOGIN_ID,
								success: function(data){
			                        if (data != "true"){
										alert(data);
			                        }else{
			                        	alert("操作成功");
			                        	$("#frozen-gridTable").trigger('reloadGrid');
			                        }
								},
								error:function(xhr){  
									show_error(xhr);
								}
							});	
						}
						break;
					default:
						alert("一次只能修改一个账户!");
				}
			}); 
	</script>
	<script type="text/javascript">
		$(function(){
			$("#unfrozen-gridTable").jqGrid({
				url: "unfrozenListQueryJson.do",
				datatype: "json",
				mtype: "POST",
				height: "100%",
				width:"100%",
				autowidth: true,
				colNames:['登录名', '姓名', '电话', '电子邮箱'],
				colModel:[
					{name:'LOGIN_ID',index:'LOGIN_ID'},
					{name:'NAME',index:'NAME'},
					{name:'LOGIN_PHONE',index:'LOGIN_PHONE'},
					{name:'EMAIL_ADDR',index:'EMAIL_ADDR'}
				],
				viewrecords: true,
				rowNum: 15,
				rowList: [10,15,30],
				sortname: 'NAME',
				jsonReader: {
					root: 'rows',
					page: 'page',
					total: 'total',
					records: 'records',
					repeatitems: false,
					subgrid: {
				        root: 'rows',
						page: 'page',
						total: 'total',
						records: 'records',
						repeatitems: false
				    }      
				},
				pager: "#unfrozen-gridPager",
				hidegrid: true,
				multiselect: true,
				beforeRequest:function(){
					var postData = {};
					$(":input[name^='userForm.']").each(function(){
						postData[$(this).attr("name")] = $(this).val();
					});
					$.extend($("#unfrozen-gridTable").getGridParam("postData"), postData);
				}
			});
			
		}); 
		$("#btn-frozen").click(function() {
				var idArr = jQuery("#unfrozen-gridTable").jqGrid('getGridParam','selarrrow');
				switch (idArr.length) {
					case 0:
						alert("请先选择一个账户!");
						break;
					case 1:
						if (confirm("是否要冻结该账户?")) {
							var data = jQuery("#unfrozen-gridTable").jqGrid('getRowData',idArr[0]);
							var LOGIN_ID = data.LOGIN_ID;
							
							$.ajax({
								type: "POST",
								async: false,
								url: "<s:url action="frozenUser" namespace='/'/>?userForm.LOGIN_ID="+LOGIN_ID,
								success: function(data){
			                        if (data != "true"){
										alert(data);
			                        }else{
			                        	alert("操作成功");
			                        	$("#unfrozen-gridTable").trigger('reloadGrid');
			                        }
								},
								error:function(xhr){  
									show_error(xhr);
								}
							});	
						}
						break;
					default:
						alert("一次只能修改一个账户!");
				}
			}); 
	</script>
</html>            
